import request from '@/utils/request'



export default {
    //查询全部
    getsendBack(searchModel) {
        return request({
            url: '/sendBack/list',
            method: 'get',

            params: {
                pageNo: searchModel.pageNo,
                pageSize: searchModel.pageSize,
                name: searchModel.name
            }
        });
    },
    //新增
    addsendBack(sendBack) {
        return request({
            url: '/sendBack',
            method: 'post',
            data: sendBack
        });
    },
    //删除
    delletesendBack(id) {
        return request({
            url: `/sendBack/${id} `,
            method: 'delete',

        });
    },
    //修改
    updatesendBack(sendBack) {
        return request({
            url: '/sendBack',
            method: 'put',
            data: sendBack
        });
    },
    //查询  by  id
    getsendBackById(id) {
        return request({
            url: `/sendBack/${id} `,
            method: 'get',

        });
    },
    savesendBack(sendBack) {
        if(sendBack.id==null && sendBack.id==undefined){
        return this.addsendBack(sendBack);
        }
         return this.updatesendBack(sendBack);   
       
    },
    // 文件上传
    uploadFile(file) {
        const formData = new FormData();
        formData.append('excelFile', file);
        return axios.post('/sendBack/upload2', formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        }).then(response => {
            if (response.data.flag) {
                this.$message.success('文件上传成功');
            } else {
                this.$message.error('文件上传失败: ' + response.data.message);
            }
        }).catch(error => {
            console.error('文件上传失败:', error);
            this.$message.error('文件上传过程中发生错误');
        });
    },
    

}